/*
 *
 * Copyright (C) 2012 Walter Lütgenau
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package offset.nodes.client.dialog.ac.view;

import java.util.ResourceBundle;

public class Privilege {

    public static final int COLUMN_NAME = 0;
    public static final int COLUMN_GRANTED = 1;
    public static final int COLUMN_DENIED = 2;
    String name;
    boolean granted;
    boolean denied;
    ResourceBundle bundle = ResourceBundle.getBundle("offset/nodes/client/dialog/view/DialogBundle");

    public Privilege(String name, boolean granted, boolean denied) {
        super();
        this.name = name;
        this.granted = granted;
        this.denied = denied;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isDenied() {
        return denied;
    }

    public void setDenied(boolean denied) {
        this.denied = denied;
    }

    public boolean isGranted() {
        return granted;
    }

    public void setGranted(boolean granted) {
        this.granted = granted;
    }

    public Object[] toArray() {
        String name = bundle.getString("privilege."+getName());
        if (name == null)
            name = getName();
        
        return new Object[]{name, new Boolean(granted), new Boolean(denied)};
    }
}
